using ELF.Modules;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;
using ProductService;
using Wolverine;
using Wolverine.RabbitMQ;

var builder = WebApplication.CreateBuilder(args);

builder.AddServiceDefaults();
// Add services to the container.

builder.Services.AddOpenTelemetry().WithTracing(config =>
{
    config.SetResourceBuilder(
        ResourceBuilder.CreateDefault().AddService(builder.Environment.ApplicationName)
        ).AddSource("Wolverine");
});

builder.Host.UseWolverine(options =>
{
    options.UseRabbitMqUsingNamedConnection("messaging").AutoProvision();
    options.PublishAllMessages().ToRabbitExchange("questions");
});
await builder.AddModulesAsync<ProductServiceModule>();

var app = builder.Build();

app.MapDefaultEndpoints();

// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
//    app.MapOpenApi();
//}

await app.InitializeModulesAsync();
app.MapControllers();

await app.RunAsync();
